package com.baox.agridata.synchronous.assembly;


import com.baox.agridata.synchronous.constant.Constant;
import com.baox.agridata.synchronous.entity.quanguo.McSzqyxx;
import com.baox.agridata.synchronous.entity.shanxi.TBASEDesignatedPigSlaughteringCompany;
import com.baox.agridata.synchronous.service.shanxi.TBaseRegionService;
import com.baox.agridata.synchronous.util.MapUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
@Slf4j
public class SlaughteringCompanyAssembly {

    @Autowired
    private TBaseRegionService tBaseRegionService;


    public TBASEDesignatedPigSlaughteringCompany getSlaughteringCompany(McSzqyxx mcSzqyxx) {
        TBASEDesignatedPigSlaughteringCompany newEntity = new TBASEDesignatedPigSlaughteringCompany();
        newEntity.setMid(mcSzqyxx.getId());
        newEntity.setName(mcSzqyxx.getMc());
        newEntity.setGuid(mcSzqyxx.getId());
        newEntity.setPlaceType(Constant.SLAUGHTERING);
        newEntity.setCode(mcSzqyxx.getQybm());
        StringBuilder sb = new StringBuilder().append(mcSzqyxx.getQhdm()).append("000000");
        Map map = tBaseRegionService.selectRegionInfoByRegionCode(sb.toString());
        log.info("区划代码：" + mcSzqyxx.getQhdm());
        if (!map.isEmpty()) {
            Integer regionId = MapUtil.getInteger(map, "ID");
            newEntity.setRegionId(regionId);
        }
        newEntity.setTel(mcSzqyxx.getDh());
        newEntity.setChargePersonName(mcSzqyxx.getFzr());
        newEntity.setAnimalId(mcSzqyxx.getDwdm());
        newEntity.setLng(mcSzqyxx.getZbx() + "");
        newEntity.setLat(mcSzqyxx.getZby() + "");
        newEntity.setRemark(mcSzqyxx.getSm());
        newEntity.setSystemStatus(mcSzqyxx.getZt().toString());
        newEntity.setPartId(Constant._PartId);
        newEntity.setCreatorId(Constant.CREATOR_ID);
        newEntity.setModifierId(Constant.MODIFIER_ID);
        newEntity.setPartitionId(Constant.PARTITION_ID);
        newEntity.setPartitionIds(Constant.PARTITION_IDS);
        newEntity.setCategoryId("ce424ec695144d8f83d92a31014b03fd");
        newEntity.setAppId(Constant.APP_ID);
        return newEntity;
    }

}
